package com.supplychainapi.service;

import com.github.pagehelper.PageInfo;
import com.joindata.inf.common.basic.exceptions.ServiceException;
import com.supplychainapi.domain.BeforeData;
import com.supplychainapi.domain.LoginCache;
import com.supplychainapi.domain.TbtreebuildDto;
import com.supplychainapi.domain.treeBuild.TreeBuildSelectItem;
import com.supplychainapi.domain.treeBuild.TreeBuildType;
import com.supplychainapi.model.ScmTbtreebuild;
import com.supplychainapi.param.ColTitle;
import com.supplychainapi.param.ScmTbtreebuildParam;

import java.util.List;
import java.util.Map;

/**
 * 供应商树结构
 *
 * @author:xiezhiwei
 * @email:xiezhiwei@niwodai.net
 * @date:2017-09-26
 */
public interface IScmTbtreebuildService {

    /**************************************供应商分类树查询start***********************************************/
    /**
     * 根据门店ID查询供应商分类信息
     *
     * @param fsShopGUID
     * @return
     * @throws ServiceException
     */
    List<ScmTbtreebuild> getScmTbtreebuildInfos(String fsShopGUID) throws ServiceException;

    /**
     * 根据门店ID查询供应商分类所有信息 不用关联关系查询  (推荐此方法)
     *
     * @param fsShopGUID   门店ID
     * @param fsTreeTypeId 分类类型
     * @return
     * @throws ServiceException
     */
    List<ScmTbtreebuild> getScmTbtreebuildAllInfo(String fsShopGUID, String fsTreeTypeId) throws ServiceException;


    /**
     * 根据门店ID查询供应商分类所有信息 不用关联关系查询  (推荐此方法)
     *
     * @param fsShopGUID   门店ID
     * @param fsTreeTypeId 分类类型
     * @return
     * @throws ServiceException
     */

    PageInfo<TbtreebuildDto> getScmTbtreebuildAllInfo(String fsShopGUID, String fsTreeTypeId, Integer pageNum, Integer pageSize) throws ServiceException;


    /**
     * 根据门店ID查询供应商分类所有信息 不用关联关系查询  (推荐此方法)
     *
     * @param fsShopGUID   门店ID
     * @param fsTreeTypeId 分类类型
     * @return
     * @throws ServiceException
     */
    List<ScmTbtreebuild> getScmTbtreebuildAllInfos(String fsShopGUID, String fsTreeTypeId, String fdNodeLevel) throws ServiceException;

    /**
     * 根据分类名称查询分类信息
     *
     * @param fsShopGUID
     * @param fsTreeTypeId
     * @param fsNodeText
     * @return
     * @throws ServiceException
     */
    List<ScmTbtreebuild> getScmTbtreebuildByFsNodeTextAllInfo(String fsShopGUID, String fsTreeTypeId, String fsNodeText) throws ServiceException;

    /**
     * 根据门店ID查询供应商分类所有信息  自己组装数据
     *
     * @param fsShopGUID
     * @return
     * @throws ServiceException
     */
    List<ScmTbtreebuild> getScmTbtreebuildAssembleInfo(String fsShopGUID, String fsTreeTypeId) throws ServiceException;

    /**************************************供应商分类树查询end***************************************************/


    /**
     * 新增分类
     *
     * @param model
     * @return
     */
    boolean saveTreeBuild(ScmTbtreebuildParam model) throws ServiceException;

    /**
     * 修改分类  根据主键  只可修改 名称
     *
     * @param model
     * @return
     */
    boolean updateTreeBuild(ScmTbtreebuildParam model) throws ServiceException;

    /**
     * 删除分类
     *
     * @param model
     * @return
     * @throws ServiceException
     */
    boolean deleteTreeBuild(ScmTbtreebuildParam model) throws ServiceException;

    /**
     * 根据主键查询 分类详情
     *
     * @param model fsNodeCode fsTreeTypeId fsShopGUID
     * @return
     */
    ScmTbtreebuild selectByKey(ScmTbtreebuildParam model) throws ServiceException;

    /**
     * 查询一级分类信息
     *
     * @param fsShopGUID   店铺GUID
     * @param fsTreeTypeId 业务类型
     * @return
     * @throws ServiceException
     */
    List<ScmTbtreebuild> getScmTbtreebuildOneLevelInfos(String fsShopGUID, Integer page, Integer pageSize, String fsTreeTypeId) throws ServiceException;


    int getQuotesByTreeBuild(String fsTreeTypeId, String fsShopGUID, String fsNodeCode);

    int getChildByTreeBuild(String fsShopGUID, String fdParentNodeCode, String fsTreeTypeId);

    PageInfo getClassListInfo(String fsShopGUID, String fsNodeText, String fsTreeTypeId, Integer pageNum,
                              Integer pageSize) throws ServiceException;

    /**
     * 标题
     *
     * @return
     */
    List<ColTitle> getSchema();

    List<TreeBuildSelectItem> getTree(String fsShopGUID, String fsTreeTypeId) throws ServiceException;

    boolean initLevel(Integer level, TreeBuildType treeBuildType, LoginCache loginCache) throws ServiceException;

    void sort(List<String> trees, String shopGuid, TreeBuildType treeBuildType) throws ServiceException;


    BeforeData addBefore(String fsNodeCode, TreeBuildType treeBuildType, String shopGuid) throws ServiceException;

    List<ScmTbtreebuild> getParentNodeCodeAndNodeCodeInfo(String fsShopGUID, String fsTreeTypeId, String fsNodeCode) throws ServiceException;


    List<ScmTbtreebuild> getAllByTypeAndShopGuid(String fsShopGUID, String fsTreeTypeId) throws ServiceException;

    List<ScmTbtreebuild> findFullCode(String shopGuid, String fullCode, String fsTreeTypeId) throws ServiceException;

    Map<String, ScmTbtreebuild> getAllByTypeAndShopGuidToMap(String fsShopGUID, String fsTreeTypeId) throws ServiceException;


    int classSorting(ScmTbtreebuildParam model);
}
